#ifndef TCPCLIENTUI_H
#define TCPCLIENTUI_H

#include <QObject>
#include <QDialog>
#include <QListWidget>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QGridLayout>

#include <QHostAddress>
#include "client.h"

class TcpClientUI : public QDialog
{
    Q_OBJECT

public:
    TcpClientUI(QWidget *parent = 0);
    ~TcpClientUI();

signals:
    //以下信号都是需要与client的槽进行connect，以便client和UI数据交换
    void connectServer(QString name, QString IP, QString port);
    void sendServer(QString msg);
    void disconnectServer();

private:
    QListWidget * contentListWidget;
    QLineEdit * sendMsg;
    QPushButton * sendBtn;
    QLabel * nameLabel;
    QLineEdit * nameLineEdit;
    QLabel * serverAddrLabel;
    QLineEdit * serverAddrLineEdit;
    QLabel * serverPortLabel;
    QLineEdit * serverPortLineEdit;
    QPushButton * connectBtn;
    QGridLayout * mainLayout;

    bool status;
    int port;

    Client * clientSocket;

protected slots:
    void slotCreateServer();
    void slotSendServer();
    void slotDisconnected();

    void updateClientUI(QString, int);

};

#endif // TCPCLIENTUI_H
